Page({
    data: {
        bannerlist: [
            ' /images/my-bg.jpg',
            ' /images/photo01.jpg',
            ' /images/my-bg.jpg',
        ],
        time: '',
        city: '',
        lilist:[],
    },

    onShow: function () {
        if (typeof this.getTabBar === 'function' && this.getTabBar()) {
            this.getTabBar().setData({
                selected: 0 //0,1，2 0-导航一  1-导航二  2-个人中心
            })
        }
        var mydate = new Date();
        var year = mydate.getFullYear();
        var month = mydate.getMonth() + 1 < 10 ? '0' + mydate.getMonth() + 1 : mydate.getMonth() + 1;
        var dat = mydate.getDate() < 10 ? '0' + mydate.getDate() : mydate.getDate();
        this.setData({
            time: year + '.' + month + '.' + dat
        })
        this.refresh();
    },
    onLoad: function (options) {
        // 这里的 name："home" 就是在 package.json中定义的名称
        wx.cloud.callFunction({
            name: 'home',
            // config: {
            //   env: 'cloud1-0gynot18c71f42a8'
            // },
            data: {
              type: 'share'
            }
          }).then((resp) => {
              console.log(resp.result);
            this.setData({
              lilist:resp.result.data
            });
         }).catch((e) => {
             console.log(e);
           
          });
    },
    refresh:function(){
        wx.cloud.callFunction({
            name: 'home',
            // config: {
            //   env: 'cloud1-0gynot18c71f42a8'
            // },
            data: {
              type: 'share'
            }
          }).then((resp) => {
              console.log(resp.result);
            this.setData({
              lilist:resp.result.data
            });
         }).catch((e) => {
             console.log(e);
           
          });
    },
    playsearch:function(){
        
    },
    //跳转到具体文章
    urlnew:function(event){
        // console.log(event);
        let id = event.currentTarget.dataset.id
        console.log(id);
        wx.navigateTo({
            url: '/mypages/news/news?titid='+id,
            //   events: events,
            success: (result) => { },
            fail: (res) => { },
            complete: (res) => { },
        })
    },
    //跳转到推荐界面
    urlgroom:function(event){
        // console.log(event);
        let id = event.currentTarget.dataset.id
        console.log(id);
        wx.navigateTo({
            url: '/mypages/groom/groom',
            //   events: events,
            success: (result) => { },
            fail: (res) => { },
            complete: (res) => { },
        })
    },
    //跳转到分享界面
    urlpub:function(event){
        // console.log(event);
        let id = event.currentTarget.dataset.id
        console.log(id);
        wx.navigateTo({
            url: '/mypages/publish/publish',
            //   events: events,
            success: (result) => { },
            fail: (res) => { },
            complete: (res) => { },
        })
    },
    //跳转到搜索界面
    urlsearch:function(){
        wx.switchTab({
          url: '/mypages/search/search',
        })
    }

})